﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="nelech.Helpers" %>
<%if (ViewData["NearLinks"] != null)
  {%>
<%
    var nearLinks = ViewData["NearLinks"] as nelech.Models.DBModel.NearLinks;%>
<table class="nearLinks">
    <% if (nearLinks.nearSprings != null && nearLinks.nearSprings.Count() > 0)
       {%>
    <tr >
        <th class="topNear">
            מעיינות קרובים:
        </th>
    </tr>
    <tr >
        <td class="middleNear">
            <table>
                <tr>
                    <td>
                        <% var spring1 = nearLinks.nearSprings[0];
                           spring1.Image.Load(); %>
                        <% if (spring1.Image.Count > 0)
                           {
                               var firstImage = spring1.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(spring1.name, 15), "SpringInfo", "Place", new { id = spring1.id }, null)%>
                    </td>
                    <td>
                        <% if (nearLinks.nearSprings.Count() > 1)
                           {
                               var spring2 = nearLinks.nearSprings[1];
                               spring2.Image.Load(); %>
                        <% if (spring2.Image.Count > 0)
                           {
                               var firstImage = spring2.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(spring2.name, 20), "SpringInfo", "Place", new { id = spring2.id }, null)%>
                        <%} %>
                    </td>
                </tr>
                 <% if (nearLinks.nearSprings.Count() > 2)
                           {%>
                <tr>
                    <td>
                       
                            <%   var spring3 = nearLinks.nearSprings[2];
                               spring3.Image.Load(); %>
                        <% if (spring3.Image.Count > 0)
                           {
                               var firstImage = spring3.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(spring3.name, 20), "SpringInfo", "Place", new { id = spring3.id }, null)%>
                       
                    </td>
                    <td>
                        <% if (nearLinks.nearSprings.Count() > 3)
                           {
                               var spring4 = nearLinks.nearSprings[3];
                               spring4.Image.Load(); %>
                        <% if (spring4.Image.Count > 0)
                           {
                               var firstImage = spring4.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(spring4.name, 20), "SpringInfo", "Place", new { id = spring4.id }, null)%>
                        <%} %>
                    </td>
                </tr>
                 <%} %>
            </table>
            <%} %>
        </td>
    </tr>
    <%if (nearLinks.nearPlaces != null && nearLinks.nearPlaces.Count() > 0 )
      { %>
    <tr >
        <th class="topNear">
            מקומות קרובים:
        </th>
    </tr>
    <tr >
        <td class="middleNear">
            <table>
                <tr>
                    <td>
                        <% var place1 = nearLinks.nearPlaces[0];
                           place1.Image.Load(); %>
                        <% if (place1.Image.Count > 0)
                           {
                               var firstImage = place1.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(place1.name, 10), "PlaceInfo", "Place", new { id = place1.id }, null)%>
                    </td>
                    <td>
                        <% if (nearLinks.nearPlaces.Count() > 1)
                           {
                               var place2 = nearLinks.nearPlaces[1];
                               place2.Image.Load(); %>
                        <% if (place2.Image.Count > 0)
                           {
                               var firstImage = place2.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(place2.name, 10), "PlaceInfo", "Place", new { id = place2.id }, null)%>
                        <%} %>
                    </td>
                </tr>
                <% if (nearLinks.nearPlaces.Count() > 2)
                           {%>
                <tr>
                    <td>
                        
                             <%  var place3 = nearLinks.nearPlaces[2];
                               place3.Image.Load(); %>
                        <% if (place3.Image.Count > 0)
                           {
                               var firstImage = place3.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(place3.name, 10), "PlaceInfo", "Place", new { id = place3.id }, null)%>
                       
                    </td>
                    <td>
                        <% if (nearLinks.nearPlaces.Count() > 3)
                           {
                               var place4 = nearLinks.nearPlaces[3];
                               place4.Image.Load(); %>
                        <% if (place4.Image.Count > 0)
                           {
                               var firstImage = place4.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(place4.name, 10), "PlaceInfo", "Place", new { id = place4.id }, null)%>
                    <%} %>
                    </td>
                </tr> <%} %>
            </table>
        </td>
    </tr>
    <%} %>
   <% if (nearLinks.nearTracks != null && nearLinks.nearTracks.Count() > 0 )
      {%> 
    <tr >
        <th class="topNear">
            טיולים קרובים:
        </th>
    </tr>
    <tr >
        <td class="middleNear">
            <table>
                <tr >
                    <td>
                        <% var track1 = nearLinks.nearTracks[0];
                           track1.Image.Load(); %>
                        <% if (track1.Image.Count > 0)
                           {
                               var firstImage = track1.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(track1.title, 10), "TrackInfo", "Track", new { id = track1.number }, null)%>
                    </td>
                    <td>
                    <% if (nearLinks.nearTracks.Count() > 1)
                       {%> 
                        <% var track2 = nearLinks.nearTracks[1];
                           track2.Image.Load();%>
                        <% if (track2.Image.Count > 0)
                           {
                               var firstImage = track2.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(track2.title, 10), "TrackInfo", "Track", new { id = track2.number }, null)%>
                    <%} %></td>
                </tr>
                <% if (nearLinks.nearTracks.Count() > 2)
                   {%> 
                <tr>
                    <td>
                        <% var track3 = nearLinks.nearTracks[2];
                           track3.Image.Load(); %>
                        <% if (track3.Image.Count > 0)
                           {
                               var firstImage = track3.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(track3.title, 10), "TrackInfo", "Track", new { id = track3.number }, null)%>
                    </td>
                    <td>
                    <% if (nearLinks.nearTracks.Count() > 3)
                       {%> 
                        <% var track4 = nearLinks.nearTracks[3];
                           track4.Image.Load(); %>
                        <% if (track4.Image.Count > 0)
                           {
                               var firstImage = track4.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(track4.title, 10), "TrackInfo", "Track", new { id = track4.number }, null)%>
                   <%} %> </td>
                </tr>
                <%} %>
            </table>
        </td>
    </tr>
    
   <%} %> 
    <% if (nearLinks.nearZimers != null && nearLinks.nearZimers.Count() > 0 )
      {%> 
    <tr >
        <th class="topNear">
            צימרים קרובים:
        </th>
    </tr>
    <tr >
        <td class="middleNear">
            <table>
                <tr >
                    <td>
                        <% var zimer1 = nearLinks.nearZimers[0];
                           zimer1.Image.Load(); %>
                        <% if (zimer1.Image.Count > 0)
                           {
                               var firstImage = zimer1.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(zimer1.name, 10), "ZimerInfo", "Track", new { id = zimer1.id }, null)%>
                    </td>
                    <td>
                    <% if (nearLinks.nearZimers.Count() > 1)
                       {%> 
                        <% var zimer2 = nearLinks.nearZimers[1];
                           zimer2.Image.Load();%>
                        <% if (zimer2.Image.Count > 0)
                           {
                               var firstImage = zimer2.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(zimer2.name, 10), "ZimerInfo", "Track", new { id = zimer2.id }, null)%>
                    <%} %></td>
                </tr>
                <% if (nearLinks.nearZimers.Count() > 2)
                   {%> 
                <tr>
                    <td>
                        <% var zimer3 = nearLinks.nearZimers[2];
                           zimer3.Image.Load(); %>
                        <% if (zimer3.Image.Count > 0)
                           {
                               var firstImage = zimer3.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(zimer3.name, 10), "ZimerInfo", "Track", new { id = zimer3.id }, null)%>
                    </td>
                    <td>
                    <% if (nearLinks.nearZimers.Count() > 3)
                       {%> 
                        <% var zimer4 = nearLinks.nearZimers[3];
                           zimer4.Image.Load(); %>
                        <% if (zimer4.Image.Count > 0)
                           {
                               var firstImage = zimer4.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(zimer4.name, 10), "ZimerInfo", "Track", new { id = zimer4.id }, null)%>
                   <%} %> </td>
                </tr>
                <%} %>
            </table>
        </td>
    </tr>
    
   <%} %> 
 <% if (nearLinks.nearAttractions != null && nearLinks.nearAttractions.Count() > 0)
       {%>
    <tr >
        <th class="topNear">
            אטרקציות קרובים:
        </th>
    </tr>
    <tr >
        <td class="middleNear">
            <table>
                <tr>
                    <td>
                        <% var attr1 = nearLinks.nearAttractions[0];
                           attr1.Image.Load(); %>
                        <% if (attr1.Image.Count > 0)
                           {
                               var firstImage = attr1.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(attr1.title, 15), "AttractionInfo", "Attraction", new { id = attr1.id }, null)%>
                    </td>
                    <td>
                        <% if (nearLinks.nearAttractions.Count() > 1)
                           {
                               var attr2 = nearLinks.nearAttractions[1];
                               attr2.Image.Load(); %>
                        <% if (attr2.Image.Count > 0)
                           {
                               var firstImage = attr2.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(attr2.title, 20), "AttractionInfo", "Attraction", new { id = attr2.id }, null)%>
                        <%} %>
                    </td>
                </tr>
                 <% if (nearLinks.nearAttractions.Count() > 2)
                           {%>
                <tr>
                    <td>
                       
                            <%   var attr3 = nearLinks.nearAttractions[2];
                                 attr3.Image.Load(); %>
                        <% if (attr3.Image.Count > 0)
                           {
                               var firstImage = attr3.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(attr3.title, 20), "AttractionInfo", "Attraction", new { id = attr3.id }, null)%>
                       
                    </td>
                    <td>
                        <% if (nearLinks.nearAttractions.Count() > 3)
                           {
                               var attr4 = nearLinks.nearAttractions[3];
                               attr4.Image.Load(); %>
                        <% if (attr4.Image.Count > 0)
                           {
                               var firstImage = attr4.Image.First();
                               var smallImageName = System.IO.Path.GetFileName(firstImage.path.Replace("\\", "/"));
                        %>
                        <img src="<%= "/Upload/Thumbs/" + smallImageName %>" alt="<%= firstImage.text %>"
                            width="78px" />
                        <% } %>
                        <br />
                        <%= Html.ActionLink(Html.Truncate(attr4.title, 20), "AttractionInfo", "Attraction", new { id = attr4.id }, null)%>
                        <%} %>
                    </td>
                </tr>
                 <%} %>
            </table>
            <%} %>
        </td>
    </tr>
</table>
<%}
         
  else
  { %>
<%} %>
